var i = true, j = false, k = this;
function l(a, b) {
  var c = b || k;
  if(arguments.length > 2) {
    var d = Array.prototype.slice.call(arguments, 2);
    return function() {
      var f = Array.prototype.slice.call(arguments);
      Array.prototype.unshift.apply(f, d);
      return a.apply(c, f)
    }
  }else {
    return function() {
      return a.apply(c, arguments)
    }
  }
}
function m(a, b) {
  function c() {
  }
  c.prototype = b.prototype;
  a.m = b.prototype;
  a.prototype = new c
}
;var n = {animationInterval:{l:75, readOnly:i}, clickBehavior:{defaultValue:"openPopup", readOnly:j, b:function(a) {
  switch(a) {
    case "openPopup":
    ;
    case "openReader":
      return i
  }
  return j
}}, extensioName:{defaultValue:"Notifier for Google Reader", readOnly:i}, protocol:{defaultValue:"https", readOnly:j, b:function(a) {
  switch(a) {
    case "http":
    ;
    case "https":
      return i
  }
  return j
}}, refreshInterval:{defaultValue:3E4, readOnly:j, b:function(a) {
  switch(a) {
    case 3E4:
      return i
  }
  return j
}}, XHRTimeout:{defaultValue:1E4, readOnly:i}};function o() {
  p(this)
}
(function(a) {
  a.h = function() {
    return a.j || (a.j = new a)
  }
})(o);
o.prototype.d = {};
o.prototype.f = {};
o.prototype.g = 5E3;
function q(a, b, c, d, f) {
  (a = a.d[b]) ? a(c, d, f) : chrome.extension.sendRequest({type:"request", requestType:b, data:c}, function(g) {
    if(g.success) {
      d(g.data)
    }else {
      f && f(g.error)
    }
  })
}
function r(a, b, c) {
  a.d[b] = c;
  var d = a.f[b];
  d && chrome.extension.onRequest.removeListener(d);
  d = function(f, g, e) {
    f.type === "request" && f.requestType === b && c(f.data, function(h) {
      e({success:i, data:h})
    }, function(h) {
      e({success:j, data:h})
    })
  };
  chrome.extension.onRequest.addListener(d);
  a.f[b] = d
}
function p() {
  chrome.extension.onRequest.addListener(function(a, b, c) {
    if(a.type === "request") {
      setTimeout(function() {
        c({success:j, error:"Timeout"})
      }, this.g)
    }else {
      a.type === "event" && c()
    }
  })
}
function s(a, b) {
  var c = n[b], d = window.localStorage[b];
  c || console.warn("Unknown option: '" + b + "'.");
  if(c.b && !c.b(d)) {
    console.warn("'" + d + "' is not valid for Option '" + b + "'.");
    return c.defaultValue
  }
  return window.localStorage[b]
}
;function t(a) {
  this.a = a
}
t.prototype.a = null;function u(a) {
  this.a = a;
  r(this.a, "unread-counts", l(this.i, this))
}
m(u, t);
function v(a, b, c, d, f) {
  function g() {
    window.clearTimeout(h);
    d()
  }
  var e = new XMLHttpRequest, h = window.setTimeout(function() {
    e.abort();
    g()
  }, s(a.a, "XHRTimeout"));
  try {
    console.groupCollapsed("Reader: request");
    console.log(b);
    console.groupEnd();
    e.onreadystatechange = function() {
      if(e.readyState === 4) {
        if(e.status >= 400) {
          g()
        }else {
          if(e.responseText) {
            console.groupCollapsed("Reader: response");
            console.log(e.responseText);
            console.groupEnd();
            var y = e.responseText;
            window.clearTimeout(h);
            c(y)
          }else {
            g()
          }
        }
      }
    };
    e.onerror = function() {
      g()
    };
    e.open(f || "GET", b, i);
    e.send(null)
  }catch(C) {
    g()
  }
}
function w(a, b, c, d, f) {
  v(a, b, function(g) {
    try {
      var e = JSON.parse(g);
      c(e)
    }catch(h) {
      d()
    }
  }, d, f)
}
function x(a, b, c, d, f) {
  c.output = "json";
  c.ck = (new Date).getTime();
  c.client = s(a.a, "extensionName");
  b = s(a.a, "protocol") + "www.google.com/reader/api/0/" + b + "?";
  var g = [], e;
  for(e in c) {
    g.push(encodeURIComponent(e) + "=" + encodeURIComponent(c[e]))
  }
  w(a, b + g.join("&"), d, f)
}
u.prototype.i = function(a, b, c) {
  var d = {};
  d.all = a.all || j;
  x(this, "unread-count", d, function(f) {
    if(a.tag) {
      for(var g = a.tag, e = 0, h;h = f.unreadcounts[e];e++) {
        if(g.test(h.id)) {
          b(h.count);
          return
        }
      }
      b(0)
    }else {
      b(f)
    }
  }, c)
};function z(a) {
  this.a = a;
  this.k = s(this.a, "refreshInterval");
  this.e()
}
m(z, t);
z.prototype.c = 0;
z.prototype.e = function() {
  A(this);
  this.c && clearTimeout(this.c);
  this.c = setTimeout(l(this.e, this), this.k)
};
function A(a) {
  q(a.a, "unread-counts", {tag:/user\/[\d]+\/state\/com\.google\/reading-list/}, function(b) {
    console.log(b)
  }, function(b) {
    console.log(b)
  })
}
;var B = o.h();
new u(B);
new z(B);
